﻿using System;
using System.Windows.Data;

namespace Rio.Framework.Pages.Helpers
{
    public class ConvertOctetsConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            long valueInOctets = System.Convert.ToInt64(value);

            long valueInKiloOctets = valueInOctets / 1024;

            if (valueInKiloOctets > 0)
            {
                return String.Format("{0} Ko", valueInKiloOctets);
            }
            else
            {
                return String.Format("{0} o", valueInOctets);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
